//
//  BYMineOrderItem.m
//  OCDemo
//
//  Created by 朱慕之 on 2022/1/4.
//

#import "BYMineOrderItem.h"


@interface BYMineOrderItem ()

/**
 * 图标
 */
@property (nonatomic, strong) UIImageView *itemImage;

/**
 * 标题
 */
@property (nonatomic, strong) UILabel *itemTitle;

@end

@implementation BYMineOrderItem

#pragma mark - SetData

- (void)setModel:(BYOrderItemModel *)model {
    _model = model;
    
    self.itemImage.image = [UIImage imageNamed:model.orderIcon];
    self.itemTitle.text = model.orderTitle;
}


#pragma mark - Init

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.itemImage];
        [self addSubview:self.itemTitle];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.itemImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.equalTo(@(kAutoWithSize(25)));
        make.centerX.equalTo(self);
        make.top.equalTo(self).offset(kAutoWithSize(20));
    }];
    
    [self.itemTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.itemImage);
        make.top.equalTo(self.itemImage.mas_bottom).offset(kAutoWithSize(10));
    }];
}


#pragma mark - LazyGet

- (UIImageView *)itemImage {
    if (!_itemImage) {
        _itemImage = [[UIImageView alloc] init];
        _itemImage.contentMode = UIViewContentModeScaleToFill;
    }
    return _itemImage;
}

- (UILabel *)itemTitle {
    if (!_itemTitle) {
        _itemTitle = [[UILabel alloc] init];
        _itemTitle.textAlignment = NSTextAlignmentCenter;
        _itemTitle.font = [UIFont systemFontOfSize:kFont(14)];
        _itemTitle.textColor = UIColorFromRGB(0x333333);
    }
    return _itemTitle;
}

@end
